package com.example.order.controller;

import com.example.order.service.OrderService;
import com.example.order.vo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RefreshScope
public class OrderController {
    @Autowired
    private OrderService orderService;

    // 配置项
    @Value("${order.demo}")
    String orderDemo;

    // 创建订单
    @PostMapping("/order/create")
    public Order createOrder(@RequestBody Order params) {
        var order = orderService.createOrder(params);
        return order;
    }

    // nacos配置中心的演示
    @GetMapping("/order/nacos/demo")
    public String getConfigDemo() {
        return "order demo value: " + orderDemo;
    }
}
